package regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class IPAddress {

    public static void main(final String[] args) {

        // String pattern = "([0-1]?[0-9]?[0-9]|(2[0-4][0-9]|25[0-5]))";
        String pattern = "(([0-1]?[0-9]?[0-9]|(2[0-4][0-9]|25[0-5]))\\.){3}([0-1]?[0-9]?[0-9]|(2[0-4][0-9]|25[0-5]))";
        Pattern compile = Pattern.compile(pattern);

        String string = "-1";
        Matcher matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "0";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "16";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "64";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "128";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "218";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "255";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "256";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "12345678";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "abcDEFghig";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "333.12.32.1";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "12.121.13.341";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "0.0.0.0";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "12.121.13.141";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "255.255.255.255";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "12.121.13.141 12.121.13.141";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "aa 12.121.13.141";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "12.121.13.141 bb";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));

        string = "aa 12.121.13.141 bb";
        matcher = compile.matcher(string);
        System.out.println(String.format("%s : %s", string, matcher.matches()));
    }
}
